package dao;

import shili.ConfigManager;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * BaseDao
 *
 * @author boy
 * @since 2023/10/25
 */
public class BaseDao {
    /**
     * 获取数据库连接对象
     */
    public static Connection getConnection(){
        Connection connection=null;
        String driver= ConfigManager.getInstance().getValue("driver");
        String url=ConfigManager.getInstance().getValue("url");
        String user=ConfigManager.getInstance().getValue("user");
        String password=ConfigManager.getInstance().getValue("password");
        try{
            Class.forName(driver);
            connection= DriverManager.getConnection(url,user,password);
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return connection;
    }

    public static void closeResource(Connection o, PreparedStatement pstmt, Runnable o1) {
    }

    public static int getConnection(Connection connection, Object[] prem, String sql, PreparedStatement pstmt) {
        return 0;
    }

}
